package com.clinic.logic.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.clinic.accessor.db.UserAccessor;
import com.clinic.entity.db.User;
import com.clinic.entity.gui.GuiUser;

@Component
public class UserLogic {
	
	@Autowired
	private UserAccessor userAccessor;
	
	public void insertUser(String name, String type, boolean admin) {
		User user = new User();
		user.setName(name);
		//user.setType(type);
		user.setAdmin(admin);
		userAccessor.insertOrUpdate(user);
	}
	
	public GuiUser getUserById(long id) {
		GuiUser guiUser = new GuiUser();
		User user = new User();
		if(user != null) {
			guiUser.setUserId(user.getUserId());
			guiUser.setName(user.getName());
			guiUser.setType(user.getType().toString());
			guiUser.setAdmin(user.isAdmin());
		}
		return guiUser;
	}
	
}